package com.hstx.demo.mqtt.controller.xml;

import com.hstx.demo.mqtt.until.ImageFormatUntil;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import org.springframework.stereotype.Controller;

import java.net.URL;
import java.util.ResourceBundle;

@Controller
public class UiTestController implements Initializable {
    public ImageView img;
    public TextArea txtare;
    public Button btnB2I;
    public Button btnI2B;

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        btnB2I.setOnMouseClicked(event -> {
            img.setImage(new Image(ImageFormatUntil.BaseToInputStream(txtare.getText().trim())));
//            ImageFormatUntil.base64StrToImage(txtare.getText().trim(), "C:\\Users\\HS001\\Pictures\\111.jpg");
        });
        btnI2B.setOnMouseClicked(event -> txtare.setText(ImageFormatUntil.imageToBase64Str("C:\\Users\\HS001\\Pictures\\如意PPT\\bbb.jpg")));
    }
}
